<?php

$catid = 1;
$num = 55;
$striptext = 30;

global $global_config, $db, $lang_global, $site_mods, $module_file, $my_head;

$my_head .= "<script type=\"text/javascript\" src=\"" . NV_BASE_SITEURL . "js/easySlider1.5.js\"></script>\n";
$my_head .="
<style type=\"text/css\">
#slider2 {
    background: #ccc;
	margin-left: 0px;
	padding-top: 5px;
	padding-bottom: 5px;
	float: left;
	width: 730px;
	margin-top:10px;
}
.ul1 {

	list-style-type: none;
	width: 730px;
	float: left;
	padding: 0px;
	margin: 0px;
}
.ul1 li {

	list-style-type: none;
	width: 730px;
	float: left;
	padding: 0px;
	margin: 0px;
}
.item1 {
	margin-left: 4px;
	float: left;
	width: 132px;
}
.img1 {
	padding-left: 0px;
	margin-left: 1px;
	margin-bottom: 10px;
	float: left;
}
p#controls { float: left; margin:0; position:relative; width:100%; }

#prevBtn,
#nextBtn { display:block; margin:0; overflow:hidden; width:10px; height:14px; position:absolute; left: 11px; top:-75px; }

#nextBtn { left:660px; }

#prevBtn a { display:block; width:10px; height:14px; background:url(" . NV_BASE_SITEURL . "js/l_arrow.gif) no-repeat 0 0; }
#nextBtn a { display:block; width:10px; height:14px; background:url(" . NV_BASE_SITEURL . "js/r_arrow.gif) no-repeat 0 0; }
</style>";


$sql = "SELECT catid,id, title, alias, hometext, homeimgalt, homeimgfile FROM `" . NV_PREFIXLANG . "_news_rows` WHERE homeimgfile!='' AND `status`= 1 AND `publtime` < " . NV_CURRENTTIME . " AND (`exptime`=0 OR `exptime`>" . NV_CURRENTTIME . ") ORDER BY `publtime` DESC LIMIT 0, " . $num;

$result = $db->sql_query ( $sql );
$numrows = $db->sql_numrows ( $result );

$data = array();
$i = 1;
while ( list ( $catid, $id, $title, $alias, $hometext, $homeimgalt, $homeimgfile ) = $db->sql_fetchrow ( $result ) )
{
	list ( $catalias ) = $db->sql_fetchrow ( $db->sql_query ( "SELECT alias FROM `" . NV_PREFIXLANG . "_news_cat` WHERE catid=" . $catid . "" ) );
	
    $link = NV_BASE_SITEURL . "?" . NV_LANG_VARIABLE . "=" . NV_LANG_DATA . "&amp;" . NV_NAME_VARIABLE . "=news&amp;" . NV_OP_VARIABLE . "=" . $catalias . "/" . $alias . "-" . $id;
	$homeimgfile = explode ( '|', $homeimgfile );
	$imglink = NV_BASE_SITEURL . NV_UPLOADS_DIR . '/news/' . $homeimgfile [0];
	$title = strip_tags ( $title );
	$title = nv_clean60 ( $title, $striptext );

	$data[$i] = array (
		"title" => $title,
		"link" => $link,
		"imglink" => $imglink,
		"homeimgalt" => $homeimgalt
	);
	$i++;
}

$xtpl = new XTemplate( "global.block_downhead.tpl", NV_ROOTDIR . "/themes/" . $global_config['site_theme'] . "/blocks/");

foreach ( $data as $i => $value )
{
	$xtpl->assign( 'DATA', $value );
	$xtpl->parse( 'main.loop.data' );
	if ( ( $i % 5 == 0 ) || ( $i == $numrows ) )
	{
		$xtpl->parse( 'main.loop' );
	}
}
$xtpl->parse( 'main' );
$content = $xtpl->text( 'main' );
?>